package demo.jdk.features.jdk5;

import java.util.ArrayList;
import java.util.List;

/**
 * @author Ranchoz  2018/9/9 8:54
 **/
public class Generic {

	public static void main(String[] args) {
		List<Integer> list1 = new ArrayList<>();
		list1.add(1);
		list1.add(2);
		list1.add(3);
		printCollection(list1);

		List<String> list2 = new ArrayList<>();
		list2.add("1");
		list2.add("2");
		list2.add("3");
		printCollection(list2);
	}

	private static void printCollection1(List<?> list) {
		list.forEach(x -> System.out.println(x));
	}

	private static void printCollection(List list) {
		list.forEach(x -> System.out.println(x));
	}


	private static void baseUse() {
		Base b1 = new Base();
		b1.setValue(1.1);
		System.out.println(b1.getValue());
	}
}


class Base <T extends Number> {
	private T value;

	public T getValue() {
		return value;
	}

	public void setValue(T value) {
		this.value = value;
	}
}

